#pragma once

namespace stl
{

	typedef struct tagMatrix3D MATRIX3D;
	typedef struct tagVector3D VECTOR3D;
	typedef struct tagPoint3D POINT3D;

	///////////////////////////////////////////////////////////////////////
	// (x0, y0, z0) -- left bottom corner
	// (x1, y1, z1) -- right top corner
	// 

	typedef struct tagBox3D
	{
		// left bottom corner
		double x0;
		double y0;
		double z0;
		// right top corner
		double x1;
		double y1;
		double z1;
	} BOX3D, *PBOX3D, *Box3DPtr;

	class GEOMCALC_API CBox3D : public BOX3D
	{
	public:
		CBox3D();
		CBox3D(double ix0, double iy0, double iz0, double ix1, double iy1, double iz1);
		CBox3D(POINT3D pt0, POINT3D pt1);
		CBox3D(BOX3D b);
		CBox3D(POINT3D p, VECTOR3D v);
		~CBox3D();

		// operator
	public:
		//// get the union box of this and box b.
		CBox3D operator+(BOX3D b) const;
		void operator+=(BOX3D b);

		//// get the intersect box of this and box b.
		CBox3D operator&(BOX3D b) const;
		void operator&=(BOX3D b);
		CBox3D operator*(double sc) const;
		void operator*= (double sc);
		CBox3D operator*(const MATRIX3D& matrix) const;
		void operator*= (const MATRIX3D& matrix);
		BOOL operator<< (BOX3D b)const;
		BOOL operator>> (BOX3D b) const;
		BOOL operator>> (POINT3D p) const;
		CBox3D operator|(BOX3D b) const;
		void operator|=(BOX3D b);

		CBox3D operator+(VECTOR3D vect) const;
		void operator+=(VECTOR3D vect);
		CBox3D operator-(VECTOR3D vect)const;
		void operator-=(VECTOR3D vect);

		// get attribs
		BOOL	IsEmpty() const;
		double	Width() const;	 //// Length of X direction
		double	Height() const; //// Length of Z direction
		double	Length()const; //// Length of Y direction

		enum RelaShip
		{
			eSeparated,
			eIntersected
		};
		RelaShip GetRelationWith(BOX3D b) const;

	protected:
		void normalize();
	};



}